
//
//  MobilePhoneViewController.m
//  DFront
//
//  Created by lanou on 15/10/28.
//  Copyright © 2015年 xuzenghui. All rights reserved.
//

#import "MobilePhoneViewController.h"
#import "MoblieTableViewController.h"
#import "iPhoneTableViewController.h"

@interface MobilePhoneViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UILabel *line;
@property (nonatomic, strong) UILabel *aline;
@property (nonatomic, strong) UIScrollView *ScrollView;
@property (nonatomic, strong) UIScrollView *aScrollView;
@end

@implementation MobilePhoneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.topView];
    [self.topView addSubview:self.backBtn];
    self.view.backgroundColor = [UIColor whiteColor];
    _ScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight - 64)];
    _ScrollView.contentSize = CGSizeMake(kScreenWidth * 2, 0);
    [self.view addSubview:_ScrollView];
    _ScrollView.delegate = self;
    _ScrollView.pagingEnabled = YES;
    _ScrollView.bounces = NO;
    _ScrollView.showsHorizontalScrollIndicator = NO;
    MoblieTableViewController *MobileVC = [[MoblieTableViewController alloc] init];
    [self addChildViewController:MobileVC];
    MobileVC.view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64);
    [_ScrollView addSubview:MobileVC.view];
    
    iPhoneTableViewController *iphoneVC = [[iPhoneTableViewController alloc] init];
    [self addChildViewController:iphoneVC];
    iphoneVC.view.frame = CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight - 64);
    [_ScrollView addSubview:iphoneVC.view];
    
    _aScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(kScreenWidth / 2 - 70, 7, kScreenWidth / 2 + 67, 36)];
    _aScrollView.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
    _aScrollView.showsHorizontalScrollIndicator = NO;
    [self.topView addSubview:_aScrollView];
    _aScrollView.contentSize = CGSizeMake(kScreenWidth / 2 + 80, 0);
    UIButton *aBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    aBtn.frame = CGRectMake(0, 0, kScreenWidth / 4, 33);
    [aBtn setTitle:@"三星" forState:UIControlStateNormal];
    [aBtn addTarget:self action:@selector(one:) forControlEvents:UIControlEventTouchUpInside];
    [_aScrollView addSubview:aBtn];
    _line = [[UILabel alloc] initWithFrame:CGRectMake(0, 33, kScreenWidth / 4, 2)];
    _line.backgroundColor = [UIColor whiteColor];
    [_aScrollView addSubview:_line];
    UIButton *bBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    bBtn.frame = CGRectMake(100, 0, kScreenWidth / 4, 33);
    [bBtn setTitle:@"iPhone" forState:UIControlStateNormal];
    [bBtn addTarget:self action:@selector(two:) forControlEvents:UIControlEventTouchUpInside];
    [_aScrollView addSubview:bBtn];
    _aline = [[UILabel alloc] initWithFrame:CGRectMake(100, 33, kScreenWidth / 4, 2)];
    _aline.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
    [_aScrollView addSubview:_aline];
    aBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    bBtn.titleLabel.font = [UIFont systemFontOfSize:16];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    if (_ScrollView.contentOffset.x / kScreenWidth == 0) {
        _line.backgroundColor = [UIColor whiteColor];
        _aline.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
    }
    else if (_ScrollView.contentOffset.x / kScreenWidth == 1)
    {
        _line.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
        _aline.backgroundColor = [UIColor whiteColor];
    }
}

- (void)one:(UIButton *)sender
{
    _ScrollView.contentOffset = CGPointMake(0, 0);
    _line.backgroundColor = [UIColor whiteColor];
    _aline.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
}

- (void)two:(UIButton *)sender
{
    _ScrollView.contentOffset = CGPointMake(kScreenWidth, 0);
    _aline.backgroundColor = [UIColor whiteColor];
    _line.backgroundColor = [UIColor colorWithRed:0.875 green:0.173 blue:0.043 alpha:1.000];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
